1. Field of the Invention
The present invention relates generally to a data processing system and, more particularly, to a method and system for delaying class loading using interface stubs.
2. Related Art
Many computing systems use object-oriented programming to better accommodate the increasing complexity and cost of large computer programs. In an object-oriented system, a xe2x80x9cclassxe2x80x9d provides a template for the creation of xe2x80x9cobjects,xe2x80x9d instances of the class, and an object includes data members and function members (methods).
In network environments, a client computer may use data obtained remotely from one or more server computers. This data is typically sent from the server computer to the client computer via a network, such as the Internet, a wide area network (WAN), or a local area network (LAN). When a client program on the client computer accesses the server computer for data, one conventional way of sending the information from the server computer to the client computer is through the use of applets, such as Java(trademark) applets. An applet is software that may, for instance, run inside a Web Browser on a client computer. Conventional applets may comprise a collection of classes and objects. These classes may, for example, establish a user interface screen on the client computer, so that the user may then use and view the data sent by the server computer.
Typically, an applet comprises multiple compiled classes, which are created from source files created by a user and written in a programming language, such as the Java(trademark) programming language further described in xe2x80x9cThe Java(trademark) Language Specification,xe2x80x9d James Gosling, Bill Joy, Guy Steele,
Addison-Wesley, 1996. Java is a trademark of Sun Microsystems, Inc. A compiler compiles the user-created source files to create the compiled classes which form the applet on the server computer.
When the client computer receives the applet from the server computer, the applet""s compiled classes may be run by an execution environment, such as the Java(trademark) Virtual Machine, a well-known execution vehicle for computer programs described in greater detail in Lindholm and Yellin, xe2x80x9cThe Java Virtual Machine Specification,xe2x80x9d Addison-Wesley, 1996.
Large applets typically suffer from download performance problems, since each class in the applet has to be downloaded to the client computer or Web browser in a separate Hyper Text Transfer Protocol (HTTP) connection, a typical Internet communication protocol. Establishing and utilizing many of these connections can be a slow process on a traditional modem line. Conventional methods attempt to remedy this problem by packaging the classes in a single archive file. These conventional methods typically place the classes in a xe2x80x9cZIPxe2x80x9d file or Java(trademark) archive file, referred to as a xe2x80x9cJARxe2x80x9d file. By placing the applet classes in an archive file, the classes can be sent from the server computer to the client computer in one HTTP connection, thereby reducing the delay associated with obtaining multiple HTTP connections.
However, if the number and size of the class files in the archive file is large, this conventional approach still suffers from performance problems. For example, if the applet archive file is large, the size of the applet archive file alone may cause a significant delay during the downloading process. Accordingly, it is desirable to improve the downloading process.
Methods and systems consistent with the present invention avoid these and other problems by enabling faster downloads of applets by delaying the loading of classes not immediately necessary for the start-up of an applet. To accomplish this goal, only classes necessary for start-up and interfaces to the delayed classes are initially passed to a client computer or Web browser. Thus, the amount of information transferred to the client computer is reduced over conventional systems, requiring less time to download. By transferring interfaces to the delayed classes, the client computer is tricked into believing that it received the entire applet. The delayed classes, the classes not initially sent, may be downloaded during the running of the applet on the client computer when they are needed, thus deferring the associated processing until necessary, which reduces the time required to perform the initial download and which avoids unnecessary processing in the event that the class is never invoked.
The advantages accruing to the present invention are numerous. Methods and systems consistent with the present invention limit the size of an archive file containing applet files by only including necessary start-up files. As a result, the smaller size of the archive file reduces the delay associated with sending the applet. Small interface references to the delayed classes are included in the archive file, and they allow the client computer to verify receipt of the entire applet. Referred to as interface xe2x80x9cstubs,xe2x80x9d these references provide a way for the delayed classes to be requested by the client computer if needed during the running of the applet. Additionally, methods and systems consistent with the present invention send one archive file and therefore eliminate the need for multiple connections to handle multiple exchanges of classes between the server computer and client computer.
In accordance with the present invention, a method is provided for sending an applet from a server computer to a client computer. This method determines a first class to be delayed on the server computer, the first class being unnecessary for start-up of the applet. It creates an interface class for the first class, wherein the interface class provides sufficient information to resolve references found in the first class, and creates on the server computer an archive file that represents the applet and that contains the interface class. This method then sends the archive file from the server computer to the client computer such that the client computer uses the interface class to resolve the references to the first class when starting the applet.